﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SteerSeparation : SteerBase
{
    public override string CName
    {
        get
        {
            return SteerName.StN_SteerSeparation;
        }
    }
    public float m_fDisFactor = 1;
    public float m_fComfortDis = 1;

    public override Vector3 CalculateForce()
    {
        Vector3 toTagForce = Vector3.zero;
        Vector3 toTag;
        float toTagLenght;
        List<GameObject> neighbors = m_pVehicle.Neighbors;
        if(neighbors != null)
        {
            for (int i = 0; i < neighbors.Count; i++)
            {
                toTag = m_pVehicle.Postion - neighbors[i].transform.position;
                toTagLenght = Mathf.Clamp(toTag.magnitude, 0.0001f, toTag.magnitude);
                toTagForce += toTag.normalized / toTagLenght;
                if(toTagLenght < m_fComfortDis)
                {
                    toTagForce *= m_fDisFactor;
                }
            }
        }
        return toTagForce;
    }

    private void Update()
    {
        
    }
}
